package com.sgb.kjwl;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.swgk.core.customview.HeightViewPager;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;

import java.util.List;

/**
 * 自动计算高度的ViewPage
 */
public abstract class BaseHeightViewPagerFragment extends AppLazyFragment {

    public static final String ARG_PARAM = "arg_param";
    public static final String ARG_PARAM_POS = "arg_param_pos";
    public static final String ARG_isRefresh = "ARG_isRefresh";
    private int position = 0;
    private boolean isRefresh = false;
    private HeightViewPager vp;
    public boolean isInitData;// 当前界面是否数据初始化完成

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        if (getArguments() != null) {
            position = getArguments().getInt(ARG_PARAM_POS, -1);
            isRefresh = getArguments().getBoolean(ARG_isRefresh, false);
            if (position != -1) {
                if (view != null && vp != null) {
                    vp.setViewForPosition(view, position);
                }
            }
        }
    }

    public void setHeightViewPager(HeightViewPager mViewPagerView) {
        vp = mViewPagerView;
    }

    public int getPosition() {
        return position;
    }

    public boolean getIsRefresh() {
        return isRefresh;
    }

    public void setIsRefresh(boolean isRefresh) {
        this.isRefresh = isRefresh;
    }

    /**
     * 需要执行刷新数据操作
     */
    public void IsRefresh(boolean isRefresh) {

    }

    public <T> void updateData(BaseRecycleAdapter<T> adapter, List<T> list, boolean isLoadMore) {
        isInitData = true;
    }
}
